package lol.clann.minecraft.springboot.api.model.reflect;

import com.ruoshui.utils.java.exception.ExceptionUtils;
import lol.clann.minecraft.springboot.api.common.Invoker;

import java.lang.reflect.Field;

/**
 *
 * @author pyz
 * @date 2019/5/2 10:37 PM
 */
public class FieldSetter extends FieldInvoker implements Invoker {

    public FieldSetter(Field field) {
        super(field);
    }

    @Override
    public Object invoke(Object target, Object... params) {
        try {
            field.set(target, params[0]);
        } catch (IllegalAccessException e) {
            ExceptionUtils.throwException(e);
        }
        return null;
    }
}
